package com.accelstack.cmp.service;

import com.accelstack.cmp.entity.ManufacturerInfo;
import com.accelstack.cmp.repository.ManufacturerInfoRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

/**
 * 制造商信息Service
 */
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class ManufacturerInfoService {
    
    private final ManufacturerInfoRepository manufacturerInfoRepository;
    
    @Transactional
    public ManufacturerInfo create(ManufacturerInfo manufacturerInfo) {
        return manufacturerInfoRepository.save(manufacturerInfo);
    }
    
    @Transactional
    public ManufacturerInfo update(ManufacturerInfo manufacturerInfo) {
        return manufacturerInfoRepository.save(manufacturerInfo);
    }
    
    @Transactional
    public void deleteById(Long id) {
        manufacturerInfoRepository.deleteById(id);
    }
    
    public Optional<ManufacturerInfo> findById(Long id) {
        return manufacturerInfoRepository.findById(id);
    }
    
    public List<ManufacturerInfo> findAll() {
        return manufacturerInfoRepository.findAll();
    }
    
    public Page<ManufacturerInfo> findAll(Pageable pageable) {
        return manufacturerInfoRepository.findAll(pageable);
    }
}

